﻿using System.Windows;
using System.Windows.Controls;

namespace AEM.Controls
{
    /// <summary>
    /// 电梯楼层模型
    /// 楼层样式 Style:普通楼层floor_normal;当前楼层:floor_now;招唤楼层:floor_ring
    /// VIP招唤 IsVipRing:是:Visibility.Visible;否:Visibility.Hidden
    /// 普通内部招唤 IsInnerRing:是:Visibility.Visible;否:Visibility.Hidden
    /// </summary>
    public partial class FloorModel : UserControl
    {
        public FloorModel()
        {
            InitializeComponent();
            
            this.vip_ring.Visibility = Visibility.Hidden;
            this.inner_ring.Visibility = Visibility.Hidden;
        }
        
        private static void OnFloorNameChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            if (args.NewValue != args.OldValue)
            {
                (sender as FloorModel).floor_name.Content = (string)args.NewValue;
            }
        }

        private static void OnIsVipRingChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            if (args.NewValue != args.OldValue)
            {
                (sender as FloorModel).vip_ring.Visibility = (Visibility)args.NewValue;
            }

        }
        private static void OnIsInnerRingChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
        {
            if (args.NewValue != args.OldValue)
            {
                (sender as FloorModel).inner_ring.Visibility = (Visibility)args.NewValue;
            }
        }

        #region 注册属性
        /// <summary>
        /// 楼层名字
        /// </summary>
        public static readonly DependencyProperty FloorNameProperty =
            DependencyProperty.Register("FloorName", typeof(string), typeof(FloorModel),
            new FrameworkPropertyMetadata("-A01", new PropertyChangedCallback(OnFloorNameChanged)));

        /// <summary>
        /// 楼层名字
        /// </summary>
        public string FloorName
        {
            get { return (string)GetValue(FloorNameProperty); }
            set { SetValue(FloorNameProperty, value); }
        }

        /// <summary>
        /// 是否Vip招唤
        /// </summary>
        public static readonly DependencyProperty IsVipRingProperty =
         DependencyProperty.Register("IsVipRing", typeof(Visibility), typeof(FloorModel),
         new FrameworkPropertyMetadata(Visibility.Hidden, new PropertyChangedCallback(OnIsVipRingChanged)));

        /// <summary>
        /// 是否Vip招唤
        /// </summary>
        public Visibility IsVipRing
        {
            get { return (Visibility)GetValue(IsVipRingProperty); }
            set { SetValue(IsVipRingProperty, value); }
        }
        
        /// <summary>
        /// 是否内部普通招唤
        /// </summary>
        public static readonly DependencyProperty IsInnerRingProperty =
         DependencyProperty.Register("IsInnerRing", typeof(Visibility), typeof(FloorModel),
         new FrameworkPropertyMetadata(Visibility.Hidden, new PropertyChangedCallback(OnIsInnerRingChanged)));

        /// <summary>
        /// 是否内部普通招唤
        /// </summary>
        public Visibility IsInnerRing
        {
            get { return (Visibility)GetValue(IsInnerRingProperty); }
            set { SetValue(IsInnerRingProperty, value); }
        }

        #endregion
    }
}
